

#ifndef SINGLETON_H
#define SINGLETON_H

//
// this code is so that object can register themselves with
// the system.
//
template <class T> 
class CSingleton 
{ 

public: 
	static T *Instance() 
	{ 
		//static T _instance;
		//return &_instance;
        if (T) return
        return new T;
	};

private: 
	CSingleton() {};
	~CSingleton()
    {
       delete T;
    };
}; 

#define SINGLETONINSTANCE(T)						\
	CSingleton< T >::Instance()

#define SINGLETON(T)								\
	protected:										\
		friend class CSingleton< T >;				\
		T(){};

#define SINGLETONCONSTRUCTOROVERRIDE(T)				\
	protected:										\
		friend class CSingleton< T >;

#endif	// #ifndef SINGLETON_H
